using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;

namespace My.IdlConverter.Core.Searchers
{
    public class Searcher
    {
        public static Interface SearchBloodParent(Method method)
        {
            Interface parent = method.Parent;
            if (!parent.IsClass())
                return parent;
            Class classParent = parent as Class;
            Debug.Assert(classParent != null);
            IList<Interface> pureInterfaces = new List<Interface>();
            classParent.GetPureBaseInterfaces(ref pureInterfaces);
            foreach (Interface nextInterface in pureInterfaces)
            {
                IList<Method> methods = nextInterface.Methods;
                foreach (Method nextMethod in methods)
                {
                    if (method.Name.Equals(nextMethod.Name))
                        return nextInterface;
                }
            }
            return null;
        }
    }
}
